<template>
  <form-create
      v-model="fapi"
      :rule="rule"
      :option="option"
      @submit="onSubmit"
  ></form-create>
</template>

<script>
import formCreate from "@form-create/ant-design-vue";

export default {
  data () {
    return {
      fapi: null,
      // rule: formCreate.parseJson('[{"type":"input","field":"ic55u71v79av","title":"输入框","info":"","_fc_drag_tag":"input","hidden":false,"display":true},{"type":"inputNumber","field":"ogm5u71v7rem","title":"计数器","info":"","_fc_drag_tag":"inputNumber","hidden":false,"display":true},{"type":"radio","field":"c9w5u71v815t","title":"单选框","info":"","effect":{"fetch":""},"options":[{"value":"1","label":"选项1"},{"value":"2","label":"选项2"}],"_fc_drag_tag":"radio","hidden":false,"display":true},{"type":"checkbox","field":"9jt1mdyip76l1","title":"多选框","info":"","effect":{"fetch":""},"options":[{"value":"1","label":"选项1"},{"value":"2","label":"选项2"}],"_fc_drag_tag":"checkbox","hidden":false,"display":true},{"type":"checkbox","field":"vzr1mdyioajnq","title":"多选框","info":"","effect":{"fetch":""},"options":[{"value":"1","label":"选项1"},{"value":"2","label":"选项2"}],"_fc_drag_tag":"checkbox","hidden":false,"display":true,"value":["1"]}]'),
      rule: formCreate.parseJson('[\n' +
          '  {\n' +
          '    "type": "input",\n' +
          '    "field": "ic55u71v79av",\n' +
          '    "title": "测试输入框",\n' +
          '    "info": "",\n' +
          '    "_fc_drag_tag": "input",\n' +
          '    "hidden": false,\n' +
          '    "display": true\n' +
          '  },\n' +
          '  {\n' +
          '    "type": "inputNumber",\n' +
          '    "field": "ogm5u71v7rem",\n' +
          '    "title": "测试计数器",\n' +
          '    "info": "",\n' +
          '    "_fc_drag_tag": "inputNumber",\n' +
          '    "hidden": false,\n' +
          '    "display": true\n' +
          '  },\n' +
          '  {\n' +
          '    "type": "radio",\n' +
          '    "field": "c9w5u71v815t",\n' +
          '    "title": "单选框1",\n' +
          '    "info": "",\n' +
          '    "effect": {\n' +
          '      "fetch": ""\n' +
          '    },\n' +
          '    "options": [\n' +
          '      {\n' +
          '        "value": "1",\n' +
          '        "label": "选项1"\n' +
          '      },\n' +
          '      {\n' +
          '        "value": "2",\n' +
          '        "label": "选项2"\n' +
          '      }\n' +
          '    ],\n' +
          '    "_fc_drag_tag": "radio",\n' +
          '    "hidden": false,\n' +
          '    "display": true\n' +
          '  },\n' +
          '  {\n' +
          '    "type": "checkbox",\n' +
          '    "field": "9jt1mdyip76l1",\n' +
          '    "title": "多选框2",\n' +
          '    "info": "",\n' +
          '    "effect": {\n' +
          '      "fetch": ""\n' +
          '    },\n' +
          '    "options": [\n' +
          '      {\n' +
          '        "value": "1",\n' +
          '        "label": "选项1"\n' +
          '      },\n' +
          '      {\n' +
          '        "value": "2",\n' +
          '        "label": "选项2"\n' +
          '      }\n' +
          '    ],\n' +
          '    "_fc_drag_tag": "checkbox",\n' +
          '    "hidden": false,\n' +
          '    "display": true\n' +
          '  },\n' +
          '  {\n' +
          '    "type": "checkbox",\n' +
          '    "field": "vzr1mdyioajnq",\n' +
          '    "title": "多选框3",\n' +
          '    "info": "",\n' +
          '    "effect": {\n' +
          '      "fetch": ""\n' +
          '    },\n' +
          '    "options": [\n' +
          '      {\n' +
          '        "value": "1",\n' +
          '        "label": "选项1"\n' +
          '      },\n' +
          '      {\n' +
          '        "value": "2",\n' +
          '        "label": "选项2"\n' +
          '      }\n' +
          '    ],\n' +
          '    "_fc_drag_tag": "checkbox",\n' +
          '    "hidden": false,\n' +
          '    "display": true,\n' +
          '    "value": [\n' +
          '      "1"\n' +
          '    ]\n' +
          '  }\n' +
          ']'),
      option: formCreate.parseJson('{"form":{"inline":false,"labelPosition":"right","size":"mini","labelWidth":"125px","hideRequiredAsterisk":false,"showMessage":true,"inlineMessage":false}}')
    }
  },
  methods: {
    onSubmit (formData) {
      console.log(formData)
      //todo 提交表单
    }
  }
  // ,components:{
  //   formCreate
  // }
}
</script>